#!/bin/bash

cd `dirname $0`
mem_sz=300m # 250 ~ 4G

url_zipkin_jar="https://dl.bintray.com/openzipkin/maven/io/zipkin/java/zipkin-server/2.10.2/zipkin-server-2.10.2-exec.jar"
_jar="zipkin-server-2.10.2-exec.jar"

if [ ! -f "$_jar" ]; then
	echo "download $url_zipkin_jar"
	wget "$url_zipkin_jar"

	if [ ! "$?" == "0" ]; then
		echo "download fail"
		exit 1
	fi
fi


if [ -f "$_jar" ]; then
	echo "run $_jar"
	nohup java -Xmx$mem_sz -Xms$mem_sz -jar "$_jar" & echo $! > run.pid 
	echo "pid="$(cat run.pid)
	tail -f nohup.out
fi
